package backstage.information.action;

import java.util.List;

import javax.servlet.http.HttpSession;

import backstage.information.pojo.Information;
import backstage.information.service.InformationService;
import backstage.staff.pojo.Staff;
import backstage.sys.action.PlatformAction;
import backstage.sys.util.Platform;
import backstage.util.pojo.Page;

public class InformationAction extends PlatformAction{

	private static final long serialVersionUID = 1L;
	
	private List<Information> info;
	private Page p;

	public String execute() throws Exception{
		HttpSession session = this.getSession();
		Staff staff = (Staff)session.getAttribute("staff");
		InformationService is = (InformationService)Platform.getInstance().getApplication().getBean("informationService");
		List<Information> list = is.getInformation(staff.getInfo());
		//if( this.p == null){
			//this.p = new Page();
			//this.p.setCurPage(1);
		//}
		//this.p = PageUtil.getNewPage(this.p,list.size());
		//this.info = list.subList((this.p.getCurPage() - 1) * this.p.getPageSize(), this.p.getCurPage() * this.p.getPageSize());
		if(list.size() > 6){
			this.info = list.subList(0,6);
		}else{
			this.info = list;
		}
		return "success";
	}
	
	public String getAllInfo() throws Exception{
		HttpSession session = this.getSession();
		Staff staff = (Staff)session.getAttribute("staff");
		InformationService is = (InformationService)Platform.getInstance().getApplication().getBean("informationService");
		this.info = is.getAllInformation(staff);
		return "success";
	}

	
	public List<Information> getInfo() {
		return info;
	}

	public void setInfo(List<Information> info) {
		this.info = info;
	}

	public Page getP() {
		return p;
	}

	public void setP(Page p) {
		this.p = p;
	}
	
}
